package com.fusetech.os.core.mapstruct;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

public interface EntityWrapper<D, E> {

    @Mappings({
            @Mapping(source = "createBy.userId", target = "createBy"),//[框架对应转换]
            @Mapping(source = "updateBy.userId", target = "updateBy")//[框架对应转换]
    })
    E toEntity(D dto);


    @Mappings({
            @Mapping(source = "createBy", target = "createBy.userId"),//[框架对应转换]
            @Mapping(source = "updateBy", target = "updateBy.userId")//[框架对应转换]
    })
    D toDTO(E entity);

    List<E> toEntity(List<D> dtoList);


    List<D> toDTO(List<E> entityList);


    Page<E> toEntity(Page<D> page);

    Page<D> toDTO(Page<E> page);

}
